package com.itheima.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.test.annotation.Rollback;

import com.itheima.domain.Standard;

public interface ProductDAO extends JpaRepository<Standard, Integer>{
	
	@Query(value="from Standard where name=?")
	public Standard findByStandard(String name);
	
	//查询不需要加modifying,但是修改数据库因为是在test包下运行会回滚所以要加上 注解 
	//@Query(value="update Standard set name=?1 where id=?2")
	@Query("update Standard s set s.name = ?1 where s.id = ?2")
	@Modifying //声明是修改操作
	@Rollback(true)
	public void updateStandard(String name,Integer id);
}
